(:
  A procedure to select the contents of the "chat" interventions
:)
declare boundary-space strip;

let $doc := doc($arguments[1])
let $isdrew := $arguments[2] = "Drew"
let $starttime := if ($isdrew) then
		$doc/trace/event[1]/time/date
	else
		$doc//record[1]//@millis
let $endtime := if ($isdrew) then
		$doc/trace/event[last()]/time/date
	else
		$doc//record[last()]//@millis
		
return
<display>
  <item>
    <info name="type">meta</info>
    <info name="starttime">{xs:string($starttime[1])}</info>
    <info name="endtime">{xs:string($endtime[1])}</info>
  </item>  
  <item>
    <info name="type">{if ($isdrew) then "forestxml" else "xml"}</info>
    <info name="filename">tracefiles/{$arguments[3]}</info>
    <info name="replayer">{$arguments[2]}</info>
    <info name="firsttime">{xs:string($starttime[1])}</info>
    <info name="lasttime">{xs:string($endtime[1])}</info>
    <info name="delta">0</info>
  </item>
</display>
